package com.shuoyue.ycgk.ui.mine.info;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.shuoyue.ycgk.Constant;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.appcatch.SPUtils;
import com.shuoyue.ycgk.base.BaseMvpActivity;
import com.shuoyue.ycgk.entity.UserInfo;
import com.shuoyue.ycgk.utils.ShareUtil;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import com.umeng.socialize.utils.SocializeUtils;

import butterknife.BindView;
import butterknife.OnClick;

public class ShareGiftActivity extends BaseMvpActivity<ShareContract.Presenter>
        implements ShareContract.View {


    @BindView(R.id.page_title)
    TextView pageTitle;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.invateNum)
    TextView invateNum;

    /**
     * 初始化layouy
     */
    @Override
    protected int getLayoutId() {
        return R.layout.activity_share_gift;
    }

    /**
     * 初始化布局
     */
    @Override
    protected void initView() {
        pageTitle.setText("分享有礼");
    }

    @Override
    public void initData() {
        super.initData();
        ivRight.setVisibility(View.VISIBLE);
        ivRight.setImageResource(R.mipmap.share);
        mPresenter = new ShareContract.Presenter();
        mPresenter.attachView(this);
        mPresenter.getInviteNum();
    }

    @Override
    public void setInviteNum(int num) {
        invateNum.setText(String.valueOf(num));
    }


    @OnClick({R.id.back, R.id.iv_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.iv_right:
                UserInfo user = SPUtils.getUserInfo(mContext);
                if (user != null) {
                    ShareUtil.shareUrl(this, ShareUtil.GIFT_URL + user.getId(),
                            "分享有礼",
                            "",
                            null);

                }

                break;
        }
    }

    private UMShareListener shareListener = new UMShareListener() {
        @Override
        public void onStart(SHARE_MEDIA platform) {
        }

        @Override
        public void onResult(SHARE_MEDIA platform) {
        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {

        }
    };

}
